//图片自适应
function imgRespone(e) {
  //用来计算高宽  
  this.setData(wxAutoImageCal(e));
  function wxAutoImageCal(e) {
    //获取图片的原始长宽  
    var originalWidth = e.detail.width;
    var originalHeight = e.detail.height;
    var windowWidth = 0, windowHeight = 0;
    var imageWidth = 0, imageHeight = 0;
    var results = {};
    //获取屏幕信息  
    wx.getSystemInfo({
      success: function (res) {
        windowWidth = res.windowWidth;
        windowHeight = res.windowHeight;
        console.log(windowHeight);
        //判断按照那种方式进行缩放  
        if (originalWidth > windowWidth) {//在图片width大于手机屏幕width时候  
          imageWidth = windowWidth;
          imageHeight = (imageWidth * originalHeight) / originalWidth;
          results.imageWidth = imageWidth;
          results.imageHeight = imageHeight;
          
        } else {//否则展示原来的数据  
          results.imageWidth = originalWidth;
          results.imageHeight = originalHeight;
        }
      }
    })
    return results;
  }
}

module.exports = {
  imgRespone: imgRespone
}